<?php
require 'user.php';
require 'function.php';
if((is_dir($path=_decode($_GET['path']))==false)) {
header('Content-Type: text/html; charset=UTF-8');
echo <<<HTML
Error：404
HTML;
exit;
}

header('Content-Type: text/html; charset=UTF-8');
echo <<<HTML
<html>
<head>
<title>文件管理－批量移动</title>
<style type="text/css">
.true{color:#6dff00;}
.false{color:#ff0000;}
.big_board{background-color:#009BCE;color:#FFF;}
.board_title{margin-bottom:1px;border:1px solid #09F;}
</style>
</head>
<body>
<div class="big_board"><div class="board_title">爱特文管－路径信息</div></div>
HTML;
echo '<a href="index.php?path='.$_GET['path'].'">'.realpath($path).'</a>';
if(count($_SESSION['path'])>=1) {
/*if(is_dir($_REQUEST['dir'])==false) {
echo <<<HTML
<div class="big_board"><div class="board_title">爱特文管－系统提示</div></div>
Hello,检测目标目录错误!
HTML;
$SESSION=null;
} else {*/
$file=$_POST['file'];
echo <<<HTML
<div class="big_board"><div class="board_title">批量重命名－结果</div></div>
<span class="true">[O]</span>已经重命名 <span class="false">[X]</span>重命名异常
HTML;
foreach($_SESSION['path'] as $i=>$ipath) {
$ipath=_decode($ipath);
$todir=$_POST['dir'].'/'.$file[$i];
echo <<<HTML
<div class="big_board"><div class="board_title"></div></div>
HTML;

if($_POST['svn']){
$cmd="svn ";
$cmd.= $_POST['copy'] ? 'copy' : 'move';
$ipath=escapeshellarg(svnpath($ipath));
$todir=escapeshellarg(svnpath($todir,false));
$cmd.=" $ipath $todir $_SESSION[key]";
if($_POST['force']) $cmd.=" --force";
echo htmlcode(cmd($cmd));
}else{
if(is_dir($ipath)) {
if($_POST['copy'] ? copydir($ipath,$todir) : rename($ipath,$todir)) {
echo '[O]<span class="true">'.basename($ipath).'/</span>';
} else {
echo '[X]<span class="false">'.basename($ipath).'/</span>';
}
}
if(is_file($ipath)) {
if($_POST['copy'] ? copy($ipath,$todir) : rename($ipath,$todir)) {
echo '[O]<span class="true">'.basename($ipath).'</span>';
} else {
echo '[X]<span class="false">'.basename($ipath).'</span>';
}
}
}

}
} else {
echo <<<HTML
<div class="big_board"><div class="board_title">爱特文管－系统提示</div></div>
Hello,待操作文件好像为空!
HTML;
}
echo <<<HTML
<div class="big_board"><div class="board_title">By：Admin@Lspecial.Com</div></div>
</body>
</html>
HTML;
unset($_SESSION['path']);
?>